<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>爱心满屏飘字</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
            background-image: linear-gradient(0deg, #eee 1px, transparent 0),
                            linear-gradient(90deg, #eee 1px, transparent 0);
            background-size: 30px 30px;
            color: #333;
            min-height: 100dvh;
            overflow: hidden;
        }

        .message-box {
            position: absolute;
            width: 200px;
            height: 100px;
            border-radius: 12px;
            box-shadow: 0 16px 35px rgba(0, 0, 0, 0.2);
            background: #fff;
            border: 1px solid rgba(0, 0, 0, 0.08);
            overflow: hidden;
            cursor: move;
            user-select: none;
            transition: transform 0.35s ease, box-shadow 0.35s ease;
            z-index: 1;
        }

        .message-box.dragging {
            transition: none;
            box-shadow: 0 22px 45px rgba(0, 0, 0, 0.35);
        }

        .title-bar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 8px 12px;
            background: rgba(255, 255, 255, 0.7);
            cursor: grab;
            user-select: none;
            touch-action: pan-y;
            height: 28px;
        }

        .title-bar.dragging {
            cursor: grabbing;
        }

        .window-controls {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .window-controls .control {
            position: relative;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            border: 1px solid rgba(0, 0, 0, 0.08);
            background: #ccc;
            cursor: pointer;
            outline: none;
            padding: 0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }

        .window-controls .control.close {
            background: #ff5f57;
            border-color: #e0443e;
        }

        .window-controls .control.minimize {
            background: #febb2e;
            border-color: #dea123;
        }

        .window-controls .control.maximize {
            background: #28c840;
            border-color: #1aab2c;
        }

        .window-controls .control::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        .title-bar:hover .window-controls .control::after {
            opacity: 0.8;
        }

        .window-controls .control.close::after {
            content: '×';
            width: auto;
            height: auto;
            background: none;
            font-size: 10px;
            line-height: 1;
            font-weight: 700;
            color: rgba(0, 0, 0, 0.7);
        }

        .window-controls .control.minimize::after {
            width: 6px;
            height: 2px;
            background: rgba(0, 0, 0, 0.6);
        }

        .window-controls .control.maximize::after {
            width: 6px;
            height: 6px;
            background: linear-gradient(
                45deg,
                rgba(0, 0, 0, 0.6) 0%,
                rgba(0, 0, 0, 0.6) 45%,
                transparent 45%,
                transparent 55%,
                rgba(0, 0, 0, 0.6) 55%,
                rgba(0, 0, 0, 0.6) 100%
            );
        }

        .title-text {
            font-size: 13px;
            font-weight: 600;
            color: rgba(0, 0, 0, 0.55);
            padding-left: 10px;
            flex: 1;
        }

        .message-content {
            padding: 16px;
            font-size: 16px;
            line-height: 1.4;
            font-weight: 600;
            color: rgba(0, 0, 0, 0.72);
            word-break: break-word;
            overflow-wrap: anywhere;
            white-space: normal;
            height: calc(100% - 28px);
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
        }

        .message-box:hover {
            transform: scale(1.05);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
        }

        @media (max-width: 768px) {
            .message-box {
                width: 180px;
                height: 90px;
            }

            .message-content {
                padding: 14px;
                font-size: 14px;
            }

            .title-text {
                font-size: 12px;
            }
        }
    </style>
</head>
<body>
    <script>
        // 定义消息内容
        const messages = [
            "我想你了", "好好吃饭!", "记得加衣!", "天天开心", "期待下一次见面",
            "愿所有烦恼都消失", "记得照顾好自己", "别感冒", "世界上最后一个纯爱",
            "遇见你是浪漫的开始", "你是我生命中的光", "每一天都更爱你", "你值得所有美好",
            "我会一直陪着你", "你是我最珍贵的礼物", "爱你到永远", "你让我的世界更美好",
            "你是我的一切", "我的心属于你", "你是我最美的梦", "你的微笑是我的阳光",
            "与你相遇好幸运", "你是我每天的期待", "有你在身边真好", "爱你无需理由",
            "你是我心中的唯一", "想和你一起慢慢变老", "你是我最想留住的幸运",
            "爱你是我做过最好的事", "你是我温暖的港湾", "你让平凡的日子发光",
            "和你在一起的每一天都很甜", "你是我人生最美的风景", "爱你如初", "你是我全部的幸福",
            "你是我最甜蜜的负担", "有你的地方就是家", "爱你到天荒地老", "你是我唯一的心动",
            "你是我今生的挚爱", "爱你胜过千言万语", "你是我生命的意义", "我的世界因你而完整"
        ];

        // 定义颜色方案 - 使用更柔和的便签颜色
        const colors = [
            '#ffe0e3', '#c7f0ff', '#ffd8a8', '#d9f2d9', '#e5d7ff',
            '#f9f7d9', '#d2f0f8', '#ffd4f5', '#e3ffe3', '#ffe8d6'
        ];

        // 存储所有消息框的列表
        let messageBoxes = [];

        // 创建消息框的函数
        function createMessage() {
            if (messageBoxes.length >= 66) {
                // 如果超过66个，移除最旧的一个
                const oldestBox = messageBoxes.shift();
                document.body.removeChild(oldestBox);
            }

            // 创建新的消息框
            const message = messages[Math.floor(Math.random() * messages.length)];
            const color = colors[Math.floor(Math.random() * colors.length)];

            const messageBox = document.createElement('div');
            messageBox.className = 'message-box';
            messageBox.style.backgroundColor = color;

            // 创建标题栏
            const titleBar = document.createElement('div');
            titleBar.className = 'title-bar';

            const titleText = document.createElement('div');
            titleText.className = 'title-text';
            titleText.textContent = '爱你';

            const closeBtn = document.createElement('button');
            closeBtn.className = 'control close';
            closeBtn.setAttribute('aria-label', '关闭');
            closeBtn.onclick = () => {
                document.body.removeChild(messageBox);
                messageBoxes = messageBoxes.filter(box => box !== messageBox);
            };

            // 添加最小化和最大化按钮（仅样式，无功能）
            const minimizeBtn = document.createElement('button');
            minimizeBtn.className = 'control minimize';
            minimizeBtn.setAttribute('aria-label', '最小化');

            const maximizeBtn = document.createElement('button');
            maximizeBtn.className = 'control maximize';
            maximizeBtn.setAttribute('aria-label', '最大化');

            const windowControls = document.createElement('div');
            windowControls.className = 'window-controls';
            windowControls.appendChild(closeBtn);
            windowControls.appendChild(minimizeBtn);
            windowControls.appendChild(maximizeBtn);

            titleBar.appendChild(windowControls);
            titleBar.appendChild(titleText);

            // 创建消息内容
            const messageContent = document.createElement('div');
            messageContent.className = 'message-content';
            messageContent.textContent = message;

            // 添加到消息框
            messageBox.appendChild(titleBar);
            messageBox.appendChild(messageContent);

            // 设置随机位置
            const x = Math.random() * (window.innerWidth - 200);
            const y = Math.random() * (window.innerHeight - 100);
            messageBox.style.left = `${x}px`;
            messageBox.style.top = `${y}px`;

            // 添加鼠标拖动功能
            let isDragging = false;
            let offsetX, offsetY;

            titleBar.addEventListener('mousedown', (e) => {
                isDragging = true;
                offsetX = e.clientX - messageBox.getBoundingClientRect().left;
                offsetY = e.clientY - messageBox.getBoundingClientRect().top;
                messageBox.classList.add('dragging');
                titleBar.classList.add('dragging');
            });

            document.addEventListener('mousemove', (e) => {
                if (isDragging) {
                    messageBox.style.left = `${e.clientX - offsetX}px`;
                    messageBox.style.top = `${e.clientY - offsetY}px`;
                }
            });

            document.addEventListener('mouseup', () => {
                isDragging = false;
                messageBox.classList.remove('dragging');
                titleBar.classList.remove('dragging');
            });

            // 添加到页面和列表
            document.body.appendChild(messageBox);
            messageBoxes.push(messageBox);

            // 随机移动
            setInterval(() => {
                if (messageBox.parentElement) {
                    const newX = Math.random() * (window.innerWidth - 200);
                    const newY = Math.random() * (window.innerHeight - 100);
                    messageBox.style.left = `${newX}px`;
                    messageBox.style.top = `${newY}px`;
                }
            }, 3000);

            // 安排下一个消息创建
            setTimeout(createMessage, 200);
        }

        // 开始创建消息
        setTimeout(createMessage, 100);
    </script>
</body>
</html>